<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
		var stus=[];//所有学生数组
			function init(){
				//1.初始化对象
				var xhr=new XMLHttpRequest();
				//2.创建请求
				xhr.open("GET","student.xml",false);//false->同步请求
				//3.发送请求
				xhr.send();
				//4.处理响应
				var xmldoc=xhr.responseXML;
				stus=xmldoc.getElementsByTagName("stu");
				//queryselectAll.....
				document.getElementById("sno").value=stus[0].getAttribute("sno");
				document.getElementById("sname").value=stus[0].getAttribute("sname");
			}
		</script>
	</head>
	<body onload="init()">
		学号：<input type="text" name="" id="sno" value="" /><br>
		姓名：<input type="text" name="" id="sname" value="" /><br>
		<button type="button" onclick="next()">下一个</button>
		<script type="text/javascript">
		var index=0;
			function next(){
				index=(index+1)%stus.length;
				document.getElementById("sno").value=stus[index].getAttribute("sno");
				document.getElementById("sname").value=stus[index].getAttribute("sname");
			}
		</script>
	</body>
</html>
